<template>
	<w-container :showCopyright="false" :hasNav="false" :isTabPage="false" :loading="loading" id='product-details'>
	<!-- 	<view class="pa-16">
			<u-subsection mode="subsection" :list="typelist" :current="typeIndex" @change="sectionChange"
				:bgColor="themeColor" :activeColor="themeColor" :inactiveColor="themeColor"></u-subsection>
		</view> -->
		<!-- <Leaderboard v-show="typeIndex == 0" ref="phb" :form="form"></Leaderboard> -->
		<joinUsers v-show="typeIndex == 1" ref="cyyh" :form="form"></joinUsers>
		<z-buttom-box padding="30rpx 2%" >
			<!-- <view style="width: 94%;" class="bg_jb_theme ptb-12 br-33 text-center font-color-white">邀请好友助力</view> -->
			<w-button @click="showPoster = true">邀请好友助力</w-button>
		</z-buttom-box>	
		<z-image-share v-model="showPoster" :sharePath="sharePath" :product='product'></z-image-share>
	</w-container>
</template>

<script>
	import Leaderboard from './components/Leaderboard.vue'
	import joinUsers from './components/joinUsers.vue'
	export default {
		components:{
			Leaderboard,
			joinUsers
		},
		data() {
			return {
				showPoster:false,
				typelist: ['抽签码排行榜', '参与用户'],
				typeIndex: 1,
				loading: false,
				form:{},
				product:{},
				sharePath:''
			}
		},
		onLoad({data}) {
			this.product = uni.getStorageSync('invitFriend')
			const { id,goods_type,batch_id } = this.product
			this.sharePath = `/pages/draw/Leaderboard/Leaderboard?id=${id}&type=${goods_type}&batch_id=${batch_id}`
			console.log(this.product,'sp');
			this.$set(this.product,'invitFriend',1) //设置邀请好友的表示，传递给路由
			if(data) this.form = JSON.parse(data)
			this.$nextTick(() => {
				this.getList()
			})
		},
		destroyed() {
			
		},
		beforeDestroy() {
			uni.removeStorageSync('invitFriend')
		},
		computed: {
			themeColor() {
				return '#42C6DA'
			}
		},
		onReachBottom() {
			if(this.typeIndex == 1) {
				this.$refs.cyyh.getList()
			}
		},
		methods: {
			getList(){
				if( this.typeIndex == 0 ) {
					this.$refs.phb.getList()
				}else {
					this.$refs.cyyh.onRefresh()
				}
			},
			sectionChange(index) {
				this.typeIndex = index;
				this.getList()
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		background-color: #f5f5f5;
	}
	
</style>
